import axios from 'axios';
import { ElMessage } from "element-plus";

const baseUrl = 'http://192.168.88.177:9875/'

// /api/v1/w3dServiceInfo/getW3dServiceInfoPage
export const getW3dServiceInfoPage = async (params) => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/getW3dServiceInfoPage';
  const result = await axios.post(url, params, {
    headers: { 'Content-Type': 'application/json; charset=UTF-8' },
  })
  return result.data;
}

// /api/v1/w3dServiceInfo/deleteW3dServiceInfoById/{id}
export const deleteW3dServiceInfoById = async (id) => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/deleteW3dServiceInfoById/' + id;
  const result = await axios.post(url)
  return result.data;
}

// /api/v1/w3dServiceInfo/insertW3dServiceInfo
export const insertW3dServiceInfo = async (params) => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/insertW3dServiceInfo';
  const result = await axios.post(url, params)
  return result.data;
}

// /api/v1/w3dServiceInfo/updateW3dServiceInfo
export const updateW3dServiceInfo = async (params) => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/updateW3dServiceInfo';
  const result = await axios.post(url, params)
  return result.data;
}

// /api/v1/w3dServiceInfo/getW3dServiceInfoCatalogue
export const getW3dServiceInfoCatalogue = async () => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/getW3dServiceInfoCatalogue';
  const result = await axios.get(url)
  return result.data;
}


// /api/v1/w3dServiceInfo/getW3dServiceInfoById
export const getW3dServiceInfoById = async (id) => {
  const url = baseUrl + '/api/v1/w3dServiceInfo/getW3dServiceInfoById?id=' + id;
  const result = await axios.get(url)
  return result.data;
}

export const startDataRequest = async (params) => {
  const token = localStorage.getItem('authorization');
  if(!token) {
    ElMessage({
      message: "登录过期，请重新登录",
      type: "error",
    });
    return;
  };
  // const url = '/datarequest/api/api-bpm/bpm/core/bpmInst/startProcess';
  const url = 'http://192.168.88.177:8002/api/api-bpm/bpm/core/bpmInst/startProcess';
  const result = await axios.post(url, params, {
    headers: {
      'Content-Type': 'application/json; charset=UTF-8',
      'authorization': 'Bearer ' + token
    },
  })
  return result.data;
}

// /api/v1/dataDashboard/getUniqueZj
export const getUniqueZj = async () => {
  const url = baseUrl + '/api/v1/dataDashboard/getUniqueZj';
  const result = await axios.get(url)
  return result.data;
}

// 获取数据范围
export const getDataEdgeFromSuperMapService = async (url) => {
  const result = await axios.get(url)
  return result.data;
}
